package com.wlyy.his.common.util.desensitization;

import org.apache.commons.lang.StringUtils;
import org.assertj.core.util.Strings;

/**
 * @ClassName DesensitizationUtils
 * @Description TODO
 * @Author zhouyanhui
 * @Date 2021-09-05 22:38
 * @Version 1.0
 **/
public class DesensitizationUtils {

    public static String desensitizedName(String fullName){
        if (StringUtils.isNotBlank(fullName)) {
            String name = StringUtils.left(fullName, 1);
            return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
        }
        return "";
    }

    public static String desensitizedPhoneNumber(String phoneNumber){
        if(StringUtils.isNotBlank(phoneNumber)){
            phoneNumber = phoneNumber.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
        }
        return phoneNumber;
    }

    public static String desensitizedIdNumber(String idNumber){
        if (StringUtils.isNotBlank(idNumber)) {
            return StringUtils.left(idNumber, 6).concat(StringUtils.removeStart(StringUtils.leftPad(StringUtils.right(idNumber, 3), StringUtils.length(idNumber), "*"), "******"));
        }
        return idNumber;
    }


    public static void main(String[] args) {
        System.out.println(desensitizedName("账单"));
    }
}
